<html>
<head><meta charset="utf-8"><title>pub macros cross crates · t-lang/pub-macro-rules · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/index.html">t-lang/pub-macro-rules</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html">pub macros cross crates</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227011496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227011496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227011496">(Feb 19 2021 at 19:04)</a>:</h4>
<p>was doing a test that checks how cross crates pub macros fail</p>



<a name="227011653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227011653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227011653">(Feb 19 2021 at 19:05)</a>:</h4>
<div class="codehilite"><pre><span></span><code>[santiago@galago pub-macro (pubrules)]$ tree
.
├── auxiliary
│   └── cross-crates.rs
└── cross-crates.rs
</code></pre></div>



<a name="227011746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227011746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227011746">(Feb 19 2021 at 19:06)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// auxiliary/cross-crates.rs</span>
<span class="cp">#![feature(pub_macro_rules)]</span><span class="w"></span>

<span class="k">pub</span><span class="w"> </span><span class="k">mod</span> <span class="nn">m</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="fm">macro_rules!</span><span class="w"> </span><span class="n">foo</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">()</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="227011837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227011837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227011837">(Feb 19 2021 at 19:06)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// cross-crates.rs</span>
<span class="c1">// check-pass</span>
<span class="c1">// aux-build:cross-crates.rs</span>

<span class="k">extern</span><span class="w"> </span><span class="k">crate</span><span class="w"> </span><span class="n">cross_crates</span><span class="p">;</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">cross_crates</span>::<span class="n">m</span>::<span class="n">foo</span><span class="o">!</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="227011846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227011846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227011846">(Feb 19 2021 at 19:06)</a>:</h4>
<p>and getting ...</p>



<a name="227011899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227011899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227011899">(Feb 19 2021 at 19:07)</a>:</h4>
<div class="codehilite"><pre><span></span><code>thread &#39;rustc&#39; panicked at &#39;Missing span for DefIndex(4)&#39;, compiler/rustc_metadata/src/rmeta/decoder.rs:718:32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&amp;template=ice.md

note: rustc 1.52.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z threads=1 -Z ui-testing -Z deduplicate-diagnostics=no -Z emit-future-incompat-report -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0

query stack during panic:
end of query stack
</code></pre></div>



<a name="227011918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227011918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227011918">(Feb 19 2021 at 19:07)</a>:</h4>
<p>which I guess it is exactly what is expected to happen</p>



<a name="227011929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227011929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227011929">(Feb 19 2021 at 19:07)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span></p>



<a name="227020680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227020680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227020680">(Feb 19 2021 at 20:05)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> interesting. ok</p>



<a name="227020758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227020758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227020758">(Feb 19 2021 at 20:06)</a>:</h4>
<p>have you looked at this panic location?</p>



<a name="227021336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227021336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227021336">(Feb 19 2021 at 20:11)</a>:</h4>
<p>yep</p>



<a name="227021441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227021441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227021441">(Feb 19 2021 at 20:11)</a>:</h4>
<p>I guess we need to add the visibility information when we compile and encode the macro</p>



<a name="227021518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/276890-t-lang/pub-macro-rules/topic/pub%20macros%20cross%20crates/near/227021518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/276890-t-lang/pub-macro-rules/topic/pub.20macros.20cross.20crates.html#227021518">(Feb 19 2021 at 20:12)</a>:</h4>
<p>and then also add the ability to decode it and then properly handle that</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>